<!--
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<div ng-class="note_folder_renderer">
  <!-- note -->
  <div ng-if="node.children == null && isFilterNote(node)" ng-mouseenter="showNoteButton=true"
       ng-mouseleave="showNoteButton=false">
    <a style="text-decoration: none;" href="#/notebook/{{node.id}}">
      <i style="font-size: 10px;"
         ng-class="query.q && node.isTrash ? 'fa fa-trash-o' : 'icon-doc'"></i> {{getNoteName(node)}}
    </a>
    <!-- if note is not in trash -->
    <a ng-if="!node.isTrash" style="text-decoration: none;">
      <i style="margin-left: 10px;"
         class="fa fa-pencil notebook-list-btn" ng-show="showNoteButton"
         ng-click="node.path ? renameNote(node.id, node.path) : renameNote(node.id, node.name)"
         tooltip-placement="bottom" uib-tooltip="Rename note">
      </i>
    </a>
    <a ng-if="!node.isTrash" style="text-decoration: none;">
      <i class="fa fa-eraser notebook-list-btn" ng-show="showNoteButton" ng-click="clearAllParagraphOutput(node.id)"
         tooltip-placement="bottom" uib-tooltip="Clear output">
      </i>
    </a>
    <a ng-if="!node.isTrash" style="text-decoration: none;">
      <i class="fa fa-trash-o notebook-list-btn" ng-show="showNoteButton" ng-click="moveNoteToTrash(node.id)"
         tooltip-placement="bottom" uib-tooltip="Move note to Trash">
      </i>
    </a>
    <!-- if note is in trash -->
    <a ng-if="node.isTrash">
      <i class="fa fa-undo notebook-list-btn" ng-show="showNoteButton" ng-click="restoreNote(node.id)"
         tooltip-placement="bottom" uib-tooltip="Restore note">
      </i>
    </a>
    <a ng-if="node.isTrash" style="font-size: 16px;">
      <i class="fa fa-times notebook-list-btn" ng-show="showNoteButton" ng-click="removeNote(node.id)"
         tooltip-placement="bottom" uib-tooltip="Remove note permanently">
      </i>
    </a>
  </div>

  <!-- folder -->
  <div ng-if="node.children != null && node.id !== TRASH_FOLDER_ID">
    <div ng-mouseenter="showFolderButton=true"
         ng-mouseleave="showFolderButton=false">
      <a style="text-decoration: none; cursor: pointer;" ng-click="toggleFolderNode(node)">
        <i style="font-size: 10px;" ng-class="node.hidden ? 'fa fa-folder' : 'fa fa-folder-open'"></i> {{getNoteName(node)}}
      </a>
      <a ng-if="!node.isTrash" href="" data-toggle="modal" data-target="#noteCreateModal" style="text-decoration: none;"
         ng-controller="NoteCreateCtrl as noteCreateCtrl" ng-click="noteCreateCtrl.getInterpreterSettings()" data-path="{{node.id}}">
        <i style="margin-left: 10px;"
           class="fa fa-plus notebook-list-btn" ng-show="showFolderButton"
           tooltip-placement="bottom" uib-tooltip="Create new note">
        </i>
      </a>
      <a ng-if="!node.isTrash" style="text-decoration: none;">
        <i class="fa fa-pencil notebook-list-btn" ng-show="showFolderButton" ng-click="renameFolder(node)"
           tooltip-placement="bottom" uib-tooltip="Rename folder">
        </i>
      </a>
      <!-- if folder is not in trash -->
      <a ng-if="!node.isTrash">
        <i class="fa fa-trash-o notebook-list-btn" ng-show="showFolderButton" ng-click="moveFolderToTrash(node.id)"
           tooltip-placement="bottom" uib-tooltip="Move folder to Trash">
        </i>
      </a>
      <!-- if folder is in trash -->
      <a ng-if="node.isTrash">
        <i class="fa fa-undo notebook-list-btn" ng-show="showFolderButton" ng-click="restoreFolder(node.id)"
           tooltip-placement="bottom" uib-tooltip="Restore folder">
        </i>
      </a>
      <a ng-if="node.isTrash" style="font-size: 16px">
        <i class="fa fa-times notebook-list-btn" ng-show="showFolderButton" ng-click="removeFolder(node.id)"
           tooltip-placement="bottom" uib-tooltip="Remove folder permanently">
        </i>
      </a>
    </div>
    <div ng-if="!node.hidden">
      <ul style="list-style-type: none; padding-left:15px;">
        <li ng-repeat="node in node.children | orderBy:node:false:noteComparator" ng-include="'app/home/notebook-template.html'" ng-class="'note_folder_renderer'"></li>
      </ul>
    </div>
  </div>
  <!-- trash folder -->
  <div ng-if="node.id === TRASH_FOLDER_ID">
    <div ng-mouseenter="showFolderButton=true"
         ng-mouseleave="showFolderButton=false">
      <a style="text-decoration: none; cursor: pointer;" ng-click="toggleFolderNode(node)">
        <i style="font-size: 14px;" class="fa fa-trash-o"></i> Trash
      </a>
      <a style="text-decoration: none;">
        <i style="margin-left: 10px"
           class="fa fa-undo notebook-list-btn" ng-show="showFolderButton" ng-click="restoreAll()"
           tooltip-placement="bottom" uib-tooltip="Restore all">
        </i>
        <i style="font-size: 16px;"
           class="fa fa-times notebook-list-btn" ng-show="showFolderButton" ng-click="emptyTrash()"
           tooltip-placement="bottom" uib-tooltip="Empty trash">
        </i>
      </a>
    </div>
    <div ng-if="!node.hidden">
      <ul style="list-style-type: none; padding-left:15px;">
        <li ng-repeat="node in node.children | orderBy:node:false:noteComparator" ng-include="'app/home/notebook-template.html'" ng-class="'note_folder_renderer'"></li>
      </ul>
    </div>
  </div>
</div>
